﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI;

namespace YArchitech.HVAC
{
	internal class QuickLocateChangeUpdate : IExternalApplication
	{
		public Result OnShutdown(UIControlledApplication application)
		{
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		public Result OnStartup(UIControlledApplication application)
		{
			QuickLocateUpdater quickLocateUpdater = new QuickLocateUpdater(application.ActiveAddInId);
			UpdaterRegistry.RegisterUpdater(quickLocateUpdater);
			ElementClassFilter item = new ElementClassFilter(typeof(Pipe));
			ElementClassFilter item2 = new ElementClassFilter(typeof(Duct));
			ElementClassFilter item3 = new ElementClassFilter(typeof(CableTray));
			ElementClassFilter item4 = new ElementClassFilter(typeof(Grid));
			ElementClassFilter item5 = new ElementClassFilter(typeof(Wall));
			LogicalOrFilter logicalOrFilter = new LogicalOrFilter(new List<ElementFilter>
			{
				item,
				item2,
				item3,
				item4,
				item5
			});
			UpdaterRegistry.AddTrigger(quickLocateUpdater.GetUpdaterId(), logicalOrFilter, Element.GetChangeTypeAny());
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
